#ifndef __MEM_SAL_H_
#define __MEM_SAL_H_

#ifdef __cplusplus
extern "C"
{
#endif

#include "system.h"


typedef struct
{
    char *name;
    uint32_t total;
    uint32_t used;
    uint32_t used_max;
} _mem_sal_info_t;


/* export func */

/* mem-sal */
void mem_init(void);
void mem_free(void *ptr);
void *mem_malloc(size_t bytes);
void *mem_realloc(void *ptr, size_t bytes);
void *mem_calloc(size_t cnt, size_t bytes);
void mem_get_info(_mem_sal_info_t *info);
char *mem_get_name(void);

/* mem-dtcm */
#if CONFIG_MEM_AREA_DTCM_ENABLE
void mem_dtcm_init(void);
void mem_dtcm_free(void *ptr);
void *mem_dtcm_malloc(size_t bytes);
void *mem_dtcm_realloc(void *ptr, size_t bytes);
void *mem_dtcm_calloc(size_t cnt, size_t bytes);
void mem_dtcm_get_info(_mem_sal_info_t *info);
char *mem_dtcm_get_name(void);
#endif // CONFIG_MEM_AREA_DTCM_ENABLE

/* mem-axi */
#if CONFIG_MEM_AREA_AXI_ENABLE
void mem_axi_init(void);
void mem_axi_free(void *ptr);
void *mem_axi_malloc(size_t bytes);
void *mem_axi_realloc(void *ptr, size_t bytes);
void *mem_axi_calloc(size_t cnt, size_t bytes);
void mem_axi_get_info(_mem_sal_info_t *info);
char *mem_axi_get_name(void);
#endif // #if CONFIG_MEM_AREA_AXI_ENABLE

/* mem-sram1 */
#if CONFIG_MEM_AREA_SRAM1_ENABLE
void mem_sram1_init(void);
void mem_sram1_free(void *ptr);
void *mem_sram1_malloc(size_t bytes);
void *mem_sram1_realloc(void *ptr, size_t bytes);
void *mem_sram1_calloc(size_t cnt, size_t bytes);
void mem_sram1_get_info(_mem_sal_info_t *info);
char *mem_sram1_get_name(void);
#endif // CONFIG_MEM_AREA_SRAM1_ENABLE

/* mem-sram2 */
#if CONFIG_MEM_AREA_SRAM2_ENABLE
void mem_sram2_init(void);
void mem_sram2_free(void *ptr);
void *mem_sram2_malloc(size_t bytes);
void *mem_sram2_realloc(void *ptr, size_t bytes);
void *mem_sram2_calloc(size_t cnt, size_t bytes);
void mem_sram2_get_info(_mem_sal_info_t *info);
char *mem_sram2_get_name(void);
#endif // CONFIG_MEM_AREA_SRAM2_ENABLE



#ifdef __cplusplus
}
#endif

#endif // __MEM_SAL_H_
